<?php

function function_a()
{
    $name = 'li';
    $age = '18';
    $sex = '1';



    function_b($name, $age, $sex);
}

function function_b($name, $age, $sex)
{
    $params = new \liyuze\Parameters\Parameters([
        'name' => $name,
        'age' => $age,
        'sex' => $sex,
    ]);
    $params->setValidateConfig([
        'name' => 'required',
        'age' => ['required', 'number', 'max' => 120, 'min' => 18,],
        'sex' => ['required']
    ]);
    //或
    $params->addValidator('name', 'required');
    $params->addValidator('age', ['required', 'number', 'max' => 120, 'min' => 18,]);

    //进行验证
    if (!$params->validate()) {
        //获取错误
        $params->getErrors();
    }
}



